﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Memont
{
    public class Rectangle
    {
        public float Length { get; set; }
        public float Width { get; set; }

        public Point CentrePoint { get; set; }

        public float CallArea()
        {
            return Length * Width;
        }
        public void Draw()
        {

            Console.WriteLine("开始画图。。。");
        }

        public MemntoRec SaveMemnto()
        {
            MemntoRec rec = new MemntoRec();
            rec.SetMemntoRec(this);
            return rec;
        }

        public void ResetState(MemntoRec rec)
        {
            rec.ResetState(this);
        }

    }

    public class MemntoRec
    {
         float Length { get; set; }
         float Width { get; set; }
         Point CentrePoint { get; set; }

        internal MemntoRec SetMemntoRec(Rectangle rectangel)
        {
            this.Length = rectangel.Length;
            this.Width = rectangel.Width;
            this.CentrePoint = rectangel.CentrePoint;
            return this;
        }

        internal void ResetState( Rectangle rectangel)
        {
            rectangel.Width = this.Width;
            rectangel.Length = this.Length;
            rectangel.CentrePoint = this.CentrePoint;
        }
    }
}
